package com.yupi.yuaiagent.agent.model;

import com.yupi.yuaiagent.advisor.MyLoggerAdvisor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class YuManus extends ToolCallAgent{


    public YuManus(ToolCallback[] allTools, @Qualifier("dashscopeChatModel") ChatModel dashscopeChatModel) {
        super(allTools);

        this.setName("YuManus");
        String SYSTEM_PROMPT = """
                You are YuManus, an all-capable AI assistant. aimed at solving any task presented by the user.
                You have various tools at you disposal that you call call upon to efficiently complete complex requests.
                """;
        this.setSystemPrompt(SYSTEM_PROMPT);
        String NEXT_STEP_PROMPT = """
                based on user needs, procatively select the most appropriate tool or combination of tools.
                For complex tasks, you can break down the problem and use different tools step by step to slove it.
                After using the tool, clearly explain the execution results an suggext the next step.
                If you want to stop the interaction at any point, use the 'terminate' tool/function call
                """;
        this.setNextStepPrompt(NEXT_STEP_PROMPT);
        this.setMaxSteps(15);
        // 初始化客户端
        ChatClient chatClient = ChatClient.builder(dashscopeChatModel)
                .defaultAdvisors(new MyLoggerAdvisor())
                .build();
        this.setChatClient(chatClient);

    }
}
